<template>
  <page-view>
    <div class="qidai" @touchstart.stop>
      <div class="title">最近受期待</div>
      <div class="qidaiBox">
        <div class="qidaiItem" v-for="(item,index) in qidaiList" :key="index">
          <img @click.stop="showqidaiImage(index)" v-lazy="item.img.replace('w.h','128.180')" alt />
          <div style="font-weight:bold">{{item.nm}}</div>
          <div>{{item.comingTitle}}</div>
        </div>
      </div>
    </div>
    <div class="movieList">
      <movie-item @showImage="showComingImage" v-for="(item,index) in comingList" :key="index" :m_item="item" :m_index="index"></movie-item>
    </div>
  </page-view>
</template>
<script>
import MovieItem from "./MovieItem.vue"
export default {
  name: "Coming",
  data() {
    return {
      comingList: [],
      qidaiList: []
    };
  },
  computed:{
    comingListPreviewImageUrls(){
      return this.comingList.map(item=>{
        let imgWidth=document.documentElement.clientWidth;
        let imgHeight=parseInt(imgWidth*180/128);
        return item.img.replace("w.h",`${imgWidth}.${imgHeight}`);
      })
    },
    qidaiListPriviewImageUrls(){
      return this.qidaiList.map(item=>{
        let imgWidth=document.documentElement.clientWidth;
        let imgHeight=parseInt(imgWidth*180/128);
        return item.img.replace("w.h",`${imgWidth}.${imgHeight}`);
      })
    }
  },
  async created() {
    /*
    this.$http.get(`/maoyanApi/ajax/comingList?ci=57&limit=20&token=`)
    this.$http.get("/maoyanApi/ajax/comingList", {
      params: {
        ci: 57,
        limit: 20,
        token: ""
      }
    });
    this.$http.post("/maoyanApi/ajax/comingList", {
      ci: 57,
      limit: 20,
      token: ""
    });
    */
   this.getComingList();
   this.getqidaiList();
  },
  methods: {
    async getComingList() {
      let resp = await this.$http.get("/maoyanApi/ajax/comingList", {
        params: {
          ci: 57,
          limit: 20,
          token: ""
        }
      });
      this.comingList = resp.data.coming;
    },
    async getqidaiList(){
      let resp = await this.$http.get("/maoyanApi/ajax/mostExpected?ci=57&limit=10&offset=0&token=")
      this.qidaiList = resp.data.coming
    },
    //期待的图片预览
    showqidaiImage(index){
      this.$showPreviewImage({
        urls:this.qidaiListPriviewImageUrls,
        current:index
      });
    },
    //即将上映的图片的预览
    showComingImage(index){
      this.$showPreviewImage({
        urls:this.comingListPreviewImageUrls,
        current:index
      })
    }
  },
  components: {
    MovieItem
  }
};
</script>

<style lang="scss" scoped>
.qidai {
  > .title {
    font-weight: bold;
    font-size: 0.28rem;
    margin: 0.08rem;
  }
  .qidaiBox {
    width: 100%;
    background-color: white;
    font-size: 0.24rem;
    display: flex;
    overflow: auto;
    .qidaiItem {
      display: flex;
      align-items: center;
      flex-direction: column;
      box-sizing: border-box;
      margin-left: 0.08rem;
      width: 2.56rem * 0.7;
      > img {
        height: 3.6rem * 0.7;
      }
    }
  }
}
//谷哥核心浏览器隐藏滚动条
::-webkit-scrollbar {
  display: none;
  background-color: transparent;
}
</style>